<%-- 
    Document   : index
    Created on : Jun 7, 2008, 12:00:30 PM
    Author     : Raed Shomali
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" session="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<jsp:useBean id="user" scope="page" class="Beans.User" />
<jsp:useBean id="database" scope="page" class="Database.PoolDatabaseManager" />


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        
        <%
        
            Object connection = database.getConnection() ;
            
            // Connection is Available?
            if( connection != null )
            {
                %> <h2>Database Works! (^^)</h2> <%
            }
            else
            {
                %> <h2>Database Unreachable :(</h2> <%                  
            }
        
        %>

        <%
            // Only if a Session Exists ...
            if( request.getSession( false ) != null )
            {
                user.setFirstName( "Raed" ) ;
                user.setLastName( "Shomali" ) ;
            
                user.setEmailAddress( "shomali11@gmail.com" ) ;
        
                request.getSession().setAttribute( "user1" , user ) ;                  
            }
        %>
        
        <form name="myForm" action="SessionTest" method="POST">
            <input type="submit" value="Session Test Me" name="myButton" />
        </form>

    </body>
</html>
